import walf
import funksvd
import pandas as pd
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
from scipy.interpolate import make_interp_spline
import os
import numpy as np
from getFuncton import get_train

x = np.arange(0, 100,5)
y=[]
data_=pd.read_csv("ratings.csv",sep="\s+")
# data_=pd.read_csv("output.csv")
for i in range(0,100,5):
    testList = []
    for j in range(10):
        data = data_
        all = get_train(data)
        train = all[0]
        test = all[1]
        data = train
        alpha=0.01*i
        try:
            mes=walf.walf(data,test,alpha)
            pass
        except Exception:
            continue
            pass
        testList.append(mes)
    y.append(np.mean(testList))

plt.plot(x, y)
filename = os.path.expanduser("getAlpha")
plt.savefig(filename)
plt.show()







